package com.yi.mall.user.controller;

import com.yi.mall.common.utils.ResponseEnum;
import com.yi.mall.common.utils.Result;
import com.yi.mall.common.model.DTO.UserReceiveAddressDTO;
import com.yi.mall.common.model.UserReceiveAddress;
import com.yi.mall.user.service.impl.UserReceiveAddressServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户收货地址表 前端控制器
 * </p>
 *
 * @author zzy
 * @since 2025-07-08
 */
@RestController
public class UserReceiveAddressController {
    @Autowired
    private UserReceiveAddressServiceImpl userReceiveAddressService;
    @PostMapping("/address/saveAddress")
    public Result save(@RequestBody UserReceiveAddress userReceiveAddress){
        userReceiveAddressService.save(userReceiveAddress);
        return Result.success(ResponseEnum.SUCCESS,userReceiveAddress);
    }
    @GetMapping("/user/address/{userId}")
    private Result listByUserId(@PathVariable Long userId){
        List<UserReceiveAddressDTO> list = userReceiveAddressService.listByUserId(userId);
        return Result.success(ResponseEnum.SUCCESS,list);
    }

}
